<template>
  <div class="row no-gutters">
    <div class="col-12 padding-20">
      <el-input placeholder="手机号/账号" v-model.trim="username"></el-input>
    </div>

    <div class="col-12">
      <el-input
        show-password
        placeholder="密码"
        v-model.trim="password"
      ></el-input>
    </div>

    <div class="col-12 padding-20" style="text-align: right">
      <span>忘记密码?</span>
    </div>

    <div class="col-12">
      <el-button @click="login()" style="width: 100%; background-color: #41b883"
        ><span style="color: white; font-size: 15px">立即登录</span></el-button
      >
    </div>
  </div>
</template>

<script>
import { fake } from "../../assets/fake";
export default {
  data() {
    return {
      username: "",
      password: "",
    };
  },
  methods: {
    login() {
      let _this = this;
      let isSuccess = false;
      fake.account.forEach((value, index) => {
        if (value.username === _this.username) {
          if (value.password === _this.password) {
            fake.self = value.user;
            isSuccess = true;
          }
        }
      });
      if (isSuccess) {
        _this.$emit("success");
        _this.$notify({
          title: "提示",
          message: "登陆成功，欢迎你",
          type: "success",
        });
        _this.username = "";
        _this.password = "";
      } else {
        _this.$message.error("账号或密码错误");
      }
    },
  },
};
</script>

<style>
</style>